<!--
 * @Description:  基于videojs
 * @Author: xuzp4
 * @Date: 2021-11-04 14:58:18
 * @LastEditors: xuzp4
 * @LastEditTime: 2021-11-04 15:02:36
 * @FilePath: \vue_demo\src\view\video2\videoPlayer.vue
-->

<template>
    <div>
        <video ref="videoPlayer" class="video-js"></video>
    </div>
</template>

<script>
import videojs from 'video.js';

export default {
    name: "VideoPlayer",
    props: {
        options: {
            type: Object,
            default() {
                return {};
            }
        }
    },
    data() {
        return {
            player: null
        }
    },
    mounted() {
        this.player = videojs(this.$refs.videoPlayer, this.options, function onPlayerReady() {
            console.log('onPlayerReady', this);
        })
    },
    beforeDestroy() {
        if (this.player) {
            this.player.dispose()
        }
    }
}
</script>